1 <?php
2 session_start();
// Use session variable on this page. This function must put on the top of page.
3 if
(!isset($_SESSION['username']) || $_SESSION['usertype'] !='admin'){ // if session variable "username" does not exist.
4 header(
"location:index.php?msg=Please%20login%20to%20access%20admin%20area%20!"); // Re-direct to index.php
5 }

6 else

7 {
8     include_once
"db.php";
9     error_reporting (E_ALL ^ E_NOTICE);
10
11 ?><!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
12 "http:
//www.w3.org/TR/html4/loose.dtd">
13 <html>
14 <head>
15 <title>Welcome to Stock Management System !</title>
16 <meta http-equiv=
"Content-Type" content="text/html; charset=iso-8859-1">
17 <META Http-Equiv=
"Cache-Control" Content="no-cache">
18 <META Http-Equiv=
"Pragma" Content="no-cache">
19 <META Http-Equiv=
"Expires" Content="0">
20 <link rel=
"stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
21         <link rel=
"stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
22         <script src=
"js/jquery.min.js" type="text/javascript"></script>
23         <script type=
"text/javascript" src="jquery.date_input.js"></script>
24 <link rel=
"stylesheet" href="date_input.css" type="text/css">
25 <script type=
"text/javascript">$(function() {
26   $(
"#datefield").date_input();
27    $(
"#due").date_input();
28 });</script>
29
30 <script type=
'text/javascript' src='lib/jquery.bgiframe.min.js'></script>
31 <script type=
'text/javascript' src='lib/jquery.ajaxQueue.js'></script>
32 <script type=
'text/javascript' src='lib/thickbox-compressed.js'></script>
33 <script type=
'text/javascript' src='jquery.autocomplete.js'></script>
34
35 <script type=
'text/javascript' src='localdata.js'></script>
36
37 <link rel=
"stylesheet" type="text/css" href="jquery.autocomplete.css" />
38 <link rel=
"stylesheet" type="text/css" href="lib/thickbox.css" />
39     
40 <script type=
"text/javascript">
41 $().ready(function() {
42
43     function log(
event, data, formatted) {
44         $(
"<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
45     }
46     
47     function formatItem(row) {
48         
return row[0] + " (<strong>id: " + row[1] + "</strong>)";
49     }
50     function formatResult(row) {
51         
return row[0].replace(/(<.+?>)/gi, '');
52     }
53     
54     
55
56
57     
58     
59     $(
"#supplier").autocomplete("supplier1.php", {
60         width:
160,
61         autoFill:
true,
62         selectFirst:
false
63     });
64     
65
66     
67 });
68
69
70 </script>
71
72         <script type=
"text/javascript" src="lib/jquery-ui-1.7.2.custom.min.js"></script>
73         <script type=
"text/javascript" src="jquery-dynamic-form.js"></script>
74         <script type=
"text/javascript">
75             $(document).ready(function(){
76                 $(
"#duplicate").dynamicForm("#plus", "#minus", {limit:50, createColor: 'yellow',removeColor: 'red'});
77                 
78             });
79         </script>
80         <script src=
"js/jquery.validationEngine-en.js" type="text/javascript"></script>
81         <script src=
"js/jquery.validationEngine.js" type="text/javascript"></script>
82          <script src=
"js/jquery.hotkeys-0.7.9.js"></script>
83         <!-- AJAX SUCCESS TEST FONCTION
84             <script>function callSuccessFunction(){alert(
"success executed")}
85                     function callFailFunction(){alert(
"fail executed")}
86             </script>
87         -->
88         
89         <script>
90         
91         function callAutoComplete(idname)
92     {
93     
94     $(
"#"+idname).autocomplete("stock.php", {
95         width:
160,
96         autoFill:
true,
97         mustMatch:
true,
98         selectFirst:
false
99     });
100     
101     
102     
103     }
104     
105     
106     function checkDublicateName()
107     {
var k=0;
108                 
for (i=0;i<=400;i=i+6)
109                     {
110                     
if($("#0"+i).length>0)
111                     { $k=
0;
112                              
for (j=0;j<=400;j=j+6)
113                             {
114                             
if($("#0"+j).length>0 && $("#0"+i).val()==$("#0"+j).val())
115                             {
116                              $k++;
117                              
118                             }
119                             }
120                         
if($k>1)
121                     {
122                     alert(
"Dublicate stock Entry. please remove new and add stock in existing one !");
123                     
124                     }
125                      
126                     }
127                     }
128                     
129                     
130                     
131                     
132                     
133     }
134
135     function callAutoAsignValue(idname)
136     {
137             
138              
var name1 = parseInt(idname,10);
139              
var quantity1 = name1+1;
140              
var brate1 = quantity1+1;
141              
var srate1 = brate1+1;
142              
var avail1 = srate1+1;
143              
var total1 = avail1+1;
144             
145              
if(parseInt(idname)>0)
146              {
147              quantity1=
"00"+quantity1;
148              brate1=
"000"+brate1;
149              srate1=
"0000"+srate1;
150              avail1=
"00000"+avail1;
151              total1=
"000000"+total1;
152              
153              }
154              
else
155              {
156               quantity1=
"00";
157               brate1=
"000";
158               srate1=
"0000";
159               avail1=
"00000";
160               total1=
"000000";
161               
162              }
163              
164                 
165         $.post(
'check_stock_details.php', {stock_name: $("#"+idname).val() },
166                 function(data){
167                 
168                                 
// if(data=='no') //if username not avaiable
169                                 
// {
170                                 
// $("#category").focus();
171                                 
// }
172                                                             
173                                 $(
"#"+brate1).val(data.buyingrate);
174                                 $(
"#"+srate1).val(data.sellingprice);
175                                 $(
"#"+avail1).val(data.available);
176                                 $(
"#quantity").focus();
177                             },
'json');
178                             
179                             
180                         checkDublicateName();
181                             
182     }
183     
184     
185     function callQKeyUp(Qidname)
186     {
187     
188             
189              
190              
var quantity = parseInt(Qidname,10);
191              
var brate = quantity+1;
192              
var srate = brate+1;
193              
var avail = srate+1;
194              
var total = avail+1;
195              
var rowcount = parseInt((total+1)/5);
196              
if(rowcount==0)
197              rowcount=
1;
198             
199              
if(parseInt(Qidname)>0)
200              {
201              quantity=
"00"+quantity;
202              brate=
"000"+brate;
203              srate=
"0000"+srate;
204              avail=
"00000"+avail;
205              total=
"000000"+total
206              }
207              
else
208              {
209               quantity=
"00";
210               brate=
"000";
211               srate=
"0000";
212               avail=
"00000";
213               total=
"000000";
214               
215               
216              }
217             
var result= parseFloat($("#"+quantity).val()) * parseFloat( $("#"+brate).val() );
218             result=result.toFixed(
2);
219             $(
"#"+total).val(result);
220             updateSubtotal();
221             
222     }
223     function balanceCalc()
224     {
if(parseFloat($("#payment").val()) > parseFloat($("#subtotal").val()))
225             $(
"#payment").val(parseFloat($("#subtotal").val()));
226             
227             
var result= parseFloat($("#subtotal").val()) - parseFloat( $("#payment").val() );
228             result=result.toFixed(
2);
229             $(
"#balance").val(result);
230     }
231     function updateSubtotal()
232     {
233                     
var temp=0;
234                     
for (i=5;i<=400;i=i+6)
235                     {
236                     
if($("#000000"+i).length>0)
237                     {
238                      temp=parseFloat(temp)+parseFloat($(
"#000000"+i).val());
239                      
240                     }
241                     }
242                 
243             
244             
var subtotal=parseFloat(temp);
245             
246             
if($("#000000").length>0)
247             {
248             
var firstrowvalue=$("#000000").val();
249             
250             subtotal=parseFloat(subtotal)+parseFloat(firstrowvalue);
251             }
252             subtotal=subtotal.toFixed(
2);
253             $(
"#subtotal").val(subtotal);
254             
255             
256     }
257     
258     function callRKeyUp(Ridname)
259     {
260              
var brate = parseInt(Ridname,10);
261              
var quantity = brate-1;
262              
var srate = brate+1;
263              
var avail = srate+1;
264              
var total = avail+1;
265              
266              
267              callQKeyUp(brate-
1)
268              
/*
269              
if(parseInt(Ridname)>0)
270              {
271              quantity=
"00"+quantity;
272              brate=
"000"+brate;
273              srate=
"0000"+srate;
274              avail=
"00000"+avail;
275              total=
"000000"+total
276              
277              }
278              
else
279              {
280               quantity=
"00";
281               brate=
"000";
282               srate=
"0000";
283               avail=
"00000";
284               total=
"000000";
285               
286              }
287             
288             
var result= parseFloat($("#"+quantity).val()) * parseFloat( $("#"+brate).val() );
289             result=result.toFixed(
2);
290             $(
"#"+total).val(result);
291             
292             updateSubtotal();
293     */

294     
295     }
296         
297         
298         $(document).ready(function() {
299             
// SUCCESS AJAX CALL, replace "success: false," by: success : function() { callSuccessFunction() },
300              $(
"#billnumber").focus();
301             
302             
/*$("#"+quantity).keyup(function (e) {
303             
304             $(
"#"+total).val( parseInt( $("#"+qunatity).val()) * parseInt( $("#"+rate).val() ));
305             
if(parseInt($("#"+quantity).val()) > parseInt($("#"+avail).val()))
306             $(
"#"+quantity).val(parseInt($("#"+avail).val()));
307             
308             });
309             
310             $(
"#"+rate).keyup(function (e) {
311             
312             $(
"#"+total).val( parseInt($("#"+quantity).val()) * parseInt($("#"+rate).val()) );
313             
if(parseInt($("#"+quantity).val()) > parseInt($("#"+avail).val()))
314             $(
"#"+quatity).val(parseInt($("#"+avail).val()));
315             
316             });
317                 */

318             
319              $(
"#supplier").blur(function()
320             {
321              
322                             
323              $.post(
'check_supplier_details.php', {stock_name1: $(this).val() },
324                 function(data){
325                 
326                                 $(
"#address").val(data.address);
327                                 $(
"#contact1").val(data.contact1);
328                                 $(
"#contact2").val(data.contact2);
329                                 
if(data.address!=undefined)
330                                 $(
"#0").focus();
331                                 
332                             },
'json');
333                                             
334                     
335
336             
337             });
338             $(
"#form1").validationEngine(),
339             
340             jQuery(document).bind(
'keydown', 'Ctrl+s',function() {
341           $(
'#form1').submit();
342           
return false;
343             });
344             
345             jQuery(document).bind(
'keydown', 'Ctrl+r',function() {
346           $(
'#form1').reset();
347           
return false;
348             });
349             jQuery(document).bind(
'keydown', 'Ctrl+a',function() {
350             window.location =
"add_purchase.php";
351           
return false;
352             });
353             jQuery(document).bind(
'keydown', 'Ctrl+0',function() {
354             window.location =
"admin.php";
355           
return false;
356             });
357             jQuery(document).bind(
'keydown', 'Ctrl+1',function() {
358             window.location =
"add_purchase.php";
359               
return false;
360             });
361             jQuery(document).bind(
'keydown', 'Ctrl+2',function() {
362             window.location =
"add_stock_sales.php";
363               
return false;
364             });
365             jQuery(document).bind(
'keydown', 'Ctrl+3',function() {
366             window.location =
"add_stock_details.php";
367               
return false;
368             });
369             jQuery(document).bind(
'keydown', 'Ctrl+4',function() {
370             window.location =
"add_category.php";
371               
return false;
372             });
373             jQuery(document).bind(
'keydown', 'Ctrl+5',function() {
374             window.location =
"add_supplier_details.php";
375               
return false;
376             });
377             jQuery(document).bind(
'keydown', 'Ctrl+6',function() {
378             window.location =
"add_customer_details.php";
379               
return false;
380             });
381             jQuery(document).bind(
'keydown', 'Ctrl+7',function() {
382             window.location =
"view_stock_entries.php";
383               
return false;
384             });
385             jQuery(document).bind(
'keydown', 'Ctrl+8',function() {
386             window.location =
"view_stock_sales.php";
387               
return false;
388             });
389             jQuery(document).bind(
'keydown', 'Ctrl+9',function() {
390             window.location =
"view_stock_details.php";
391               
return false;
392             });
393             
394             jQuery(document).bind(
'keyup', 'Ctrl+down',function() {
395             $(
'#plus').click();
396               
return false;
397             });
398             
//$.validationEngine.loadValidation("#date")
399             
//alert($("#formID").validationEngine({returnIsValid:true}))
400             
//$.validationEngine.buildPrompt("#date","This is an example","error") // Exterior prompt build example // input prompt close example
401             
//$.validationEngine.closePrompt(".formError",true) // CLOSE ALL OPEN PROMPTS
402         });
403     </script>
404 <style type=
"text/css">
405 <!--
406 body {
407     margin-left: 0px;
408     margin-top: 0px;
409     margin-right: 0px;
410     margin-bottom: 0px;
411     background-color: #FFFFFF;
412 }
413
414 *{
415 padding: 0px;
416 margin: 0px;
417 }
418 #vertmenu {
419 font-family: Verdana, Arial, Helvetica, sans-serif;
420 font-size:
100%;
421 width: 160px;
422 padding: 0px;
423 margin: 0px;
424 }
425
426 #vertmenu h1 {
427 display: block;
428 background-color:#FF9900;
429 font-size:
90%;
430 padding: 3px
0 5px 3px;
431 border: 1px solid #
000000;
432 color: #
333333;
433 margin: 0px;
434 width:159px;
435 }
436
437 #vertmenu ul {
438 list-style: none;
439 margin: 0px;
440 padding: 0px;
441 border: none;
442 }
443 #vertmenu ul li {
444 margin: 0px;
445 padding: 0px;
446 }
447 #vertmenu ul li a {
448 font-size:
80%;
449 display: block;
450 border-bottom: 1px dashed #C39C4E;
451 padding: 5px 0px 2px 4px;
452 text-decoration: none;
453 color: #
666666;
454 width:160px;
455 }
456
457 #vertmenu ul li a:hover, #vertmenu ul li a:focus {
458 color: #
000000;
459 background-color: #eeeeee;
460 }
461 .style1 {color: #
000000}
462 div.pagination {
463
464     padding: 3px;
465
466     margin: 3px;
467
468 }
469
470
471
472 div.pagination a {
473
474     padding: 2px 5px 2px 5px;
475
476     margin: 2px;
477
478     border: 1px solid #AAAADD;
479
480     
481
482     text-decoration: none;
/* no underline */
483
484     color: #
000099;
485
486 }
487
488 div.pagination a:hover, div.pagination a:active {
489
490     border: 1px solid #
000099;
491
492
493
494     color: #
000;
495
496 }
497
498 div.pagination span.current {
499
500     padding: 2px 5px 2px 5px;
501
502     margin: 2px;
503
504         border: 1px solid #
000099;
505
506         
507
508         font-weight: bold;
509
510         background-color: #
000099;
511
512         color: #FFF;
513
514     }
515
516     div.pagination span.disabled {
517
518         padding: 2px 5px 2px 5px;
519
520         margin: 2px;
521
522         border: 1px solid #EEE;
523
524     
525
526         color: #DDD;
527
528     }
529
530     
531 -->
532 </style>
533
534
535 </head>
536
537 <body>
538 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
539   <tr>
540     <td align=
"center" valign="top"><table width="960" border="0" cellspacing="0" cellpadding="0">
541       <tr>
542         <td><table width=
"960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
543           <tr>
544             <td height=
"90" align="left" valign="top"><img src="images/topbanner.jpg" width="960" height="82"></td>
545           </tr>
546           <tr>
547             <td height=
"500" align="left" valign="top"><table width="960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
548               <tr>
549                 <td width=
"130" align="left" valign="top">
550                 
551                 <br>
552
553                 <strong>Welcome <font color=
"#3399FF"><?php echo $_SESSION['username']; ?> !</font></strong><br> <br>
554 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
555   <tr>
556     <td align=
"center"><a href="admin.php"><img src="images/home.png" width="130" height="99" border="0"></a></td>
557     </tr>
558   <tr>
559     <td align=
"center">&nbsp;</td>
560     </tr>
561   <tr>
562     <td align=
"center"><a href="add_purchase.php"><img src="images/purchase.png" width="130" height="124" border="0"></a></td>
563     </tr>
564   <tr>
565     <td align=
"center">&nbsp;</td>
566     </tr>
567   <tr>
568     <td align=
"center"><a href="add_stock_sales.php"><img src="images/sales.png" width="146" height="111" border="0"></a></td>
569     </tr>
570   <tr>
571     <td align=
"center">&nbsp;</td>
572     </tr>
573   <tr>
574     <td align=
"center"><a href="report.php"><img src="images/reports.png" width="131" height="142" border="0"></a></td>
575     </tr>
576   <tr>
577     <td align=
"center">&nbsp;</td>
578     </tr>
579   <tr>
580     <td align=
"center">&nbsp;</td>
581     </tr>
582   <tr>
583     <td align=
"center">&nbsp;</td>
584     </tr>
585 </table>
586
587
588     
589                 
590                 
591                 </td> <td height=
"500" align="center" valign="top">
592 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
593   <tr>
594     <td><a href=
"add_stock_details.php"><img src="images/addstockdetails.png" width="67" height="62" border="0"></a></td>
595     <td><a href=
"add_supplier_details.php"><img src="images/supplier.png" width="67" height="54" border="0"></a></td>
596     <td><a href=
"add_customer_details.php"><img src="images/customer.png" width="67" height="54" border="0"></a></td>
597     <td><a href=
"add_category.php"><img src="images/categories.png" width="67" height="54" border="0"></a></td>
598     <td><a href=
"view_stock_sales.php"><img src="images/vsales.png" width="67" height="54" border="0"></a></td>
599     <td><a href=
"view_stock_entries.php"><img src="images/vpurchase.png" width="67" height="54" border="0"></a></td>
600     <td><a href=
"view_stock_details.php"><img src="images/stockdetails.png" width="67" height="54" border="0"></a></td>
601     <td><a href=
"view_stock_availability.php"><img src="images/savail.png" width="67" height="54" border="0"></a></td>
602      <td align=
"left" valign="top"><a href="view_customer_details.php"><img src="images/customers.png" width="94" height="22" border="0"></a><br> <a href="view_supplier_details.php"><img src="images/suppliers.png" width="94" height="22" border="0"></a><br>
603       <a href=
"view_payments.php"><img src="images/payments.png" width="94" height="22" border="0"></a></td>
604     <td align=
"left" valign="top"><a href="view_stock_sales_payments.php"><img src="images/outstanding.png" width="94" height="22" border="0"></a><br> <a href="view_stock_entries_payments.php"><img src="images/pendings.png" width="94" height="22" border="0"></a><br>
605       <a href=
"logout.php"><img src="images/logout.png" width="94" height="22" border="0"></a></td>
606   </tr>
607 </table>
608                 <?php
609                 
if(isset($_POST['name']))
610
611             {
612             $billnumber=mysql_real_escape_string($_POST[
'billnumber']);
613             $autoid=mysql_real_escape_string($_POST[
'id']);
614             
615             $supplier=mysql_real_escape_string($_POST[
'supplier']);
616             $address=mysql_real_escape_string($_POST[
'address1']);
617             $contact1=mysql_real_escape_string($_POST[
'contact1']);
618             $contact2=mysql_real_escape_string($_POST[
'contact2']);
619             $payment=mysql_real_escape_string($_POST[
'payment']);
620             $balance=mysql_real_escape_string($_POST[
'balance']);
621                 $temp_balance = $db->queryUniqueValue(
"SELECT balance FROM supplier_details WHERE supplier_name='$supplier'");
622                 $temp_balance = (
int) $temp_balance + (int) $balance;
623                 $db->execute(
"UPDATE supplier_details SET balance=$temp_balance WHERE supplier_name='$supplier'");
624             $selected_date=$_POST[
'due'];
625             $selected_date=strtotime( $selected_date );
626             $mysqldate = date(
'Y-m-d H:i:s', $selected_date );
627             $due=$mysqldate;
628             $mode=mysql_real_escape_string($_POST[
'mode']);
629             $description=mysql_real_escape_string($_POST[
'description']);
630             
631             $namet=$_POST[
'name'];
632             $quantityt=$_POST[
'quanitity'];
633             $bratet=$_POST[
'brate'];
634             $sratet=$_POST[
'srate'];
635             $totalt=$_POST[
'total'];
636             
637             $subtotal=mysql_real_escape_string($_POST[
'subtotal']);
638             
639             $username=$_SESSION[
'username'];
640             
641             $i=
0;
642             $j=
1;
643             $username = $_SESSION[
'username'];
644                     
645         $selected_date=$_POST[
'date'];
646             $selected_date=strtotime( $selected_date );
647             $mysqldate = date(
'Y-m-d H:i:s', $selected_date );
648             
649               
foreach($namet as $name1)
650                {
651                
652             $quantity=$_POST[
'quantity'][$i];
653             $brate=$_POST[
'brate'][$i];
654             $srate=$_POST[
'srate'][$i];
655             $total=$_POST[
'total'][$i];
656             $sysid=$_POST[
'sysid'][$i];
657             
658             
659             $count = $db->countOf(
"stock_avail", "name='$name1'");
660             
if($count == 0)
661             {
662             $db->query(
"insert into stock_avail(name,quantity) values('$name1',$quantity)");
663             echo
"<br><font color=green size=+1 >New Stock Entry Inserted !</font>" ;
664                
665             $db->query(
"insert into stock_details(stock_id,stock_name,stock_quatity,supplier_id,company_price,selling_price) values('$autoid','$name1',0,'$suplier',$brate,$srate)");
666              
667               
668             
669             
670             $db->query(
"UPDATE stock_entries SET stock_name='$name1', stock_supplier_name='$supplier', quantity=$quantity, company_price=$brate, selling_price=$srate, opening_stock=0, closing_stock=$quantity, date='$mysqldate', username='$username', type='entry', total=$total, payment=$payment, balance=$balance, mode='$mode', description='$description', due='$due', subtotal=$subtotal,billnumber='$billnumber' WHERE stock_id='$autoid' AND count1=$j");
671             
672             }
673             
674             
else if($count==1)
675             {
676                 $amount = $db->queryUniqueValue(
"SELECT quantity FROM stock_avail WHERE name='$name1'");
677                 $oldquantity = $db->queryUniqueValue(
"SELECT quantity FROM stock_entries WHERE stock_id='$autoid' AND count1=$j");
678                 $amount1 = ($amount + $quantity) - $oldquantity;
679                 
if($quantity > $oldquantity)
680                 {
681                 $difference = $quantity - $oldquantity;
682                 $result = $db->query(
"SELECT opening_stock,closing_stock FROM stock_entries WHERE id > $sysid");
683                 
while ($line10 = $db->fetchNextObject($result)) {
684                 
685                 $old_opening_stock = $line10->opening_stock;
686                 $new_opening_stock = $old_opening_stock + $difference;
687                 
688                 $old_closing_stock = $line10->closing_stock;
689                 $new_closing_stock = $old_closing_stock + $difference;
690                 
691                 
692                 $db->execute(
"UPDATE stock_entries SET opening_stock=$new_opening_stock,closing_stock=$new_closing_stock WHERE id=$line10->id");
693
694                 }
695                 
696                 }
697                 
698                 
699                     
if($quantity < $oldquantity)
700                 {
701                 $difference = $oldquantity - $quantity ;
702                 $result = $db->query(
"SELECT opening_stock,closing_stock FROM stock_entries WHERE id > $sysid");
703                 
while ($line10 = $db->fetchNextObject($result)) {
704                 
705                 $old_opening_stock = $line10->opening_stock;
706                 $new_opening_stock = $old_opening_stock - $difference;
707                 
708                 $old_closing_stock = $line10->closing_stock;
709                 $new_closing_stock = $old_closing_stock - $difference;
710                 
711                 
712                 $db->execute(
"UPDATE stock_entries SET opening_stock=$new_opening_stock,closing_stock=$new_closing_stock WHERE id=$line10->id");
713
714                 }
715                 
716                 }
717                 
718                 $db->execute(
"UPDATE stock_avail SET quantity=$amount1 WHERE name='$name1'");
719             $db->query(
"UPDATE stock_entries SET stock_name='$name1', stock_supplier_name='$supplier', quantity=$quantity, company_price=$brate, selling_price=$srate, opening_stock=$amount, closing_stock=$amount1, date='$mysqldate', username='$username', type='entry', total=$total, payment=$payment, balance=$balance, mode='$mode', description='$description', due='$due', subtotal=$subtotal,billnumber='$billnumber' WHERE stock_id='$autoid' AND count1=$j");
720             
//INSERT INTO `stock`.`stock_entries` (`id`, `stock_id`, `stock_name`, `stock_supplier_name`, `category`, `quantity`, `company_price`, `selling_price`, `opening_stock`, `closing_stock`, `date`, `username`, `type`, `salesid`, `total`, `payment`, `balance`, `mode`, `description`, `due`, `subtotal`, `count1`)
721             
//VALUES (NULL, '$autoid1', '$name1', '$supplier', '', '$quantity', '$brate', '$srate', '$amount', '$amount1', '$mysqldate', 'sdd', 'entry', 'Sa45', '432.90', '2342.90', '24.34', 'cash', 'sdflj', '2010-03-25 12:32:02', '45645', '1');
722             
723             
724                 
725             
726             }
727             
728             
729                 
730             
731             
732             
733             
734             
735             $i++;
736             $j++;
737             }
738                 echo
"<br><font color=green size=+1 >Parchase order Updated successfully Ref: [ $autoid] !</font>" ;
739                 
740                 
741                 
742                 }
743                 ?>
744                 
745                 <br>
746 <br>
747
748                 
749                 
750                   
751                   <p align=
"center"><strong>Add New Purchase Entry </strong> - Add New ( Control +A)<?php
752
753 if
(isset($_GET['id']))
754                 {
755                 
756                 $id=$_GET[
'id'];
757                 
758                 
759                 $line = $db->queryUniqueObject(
"SELECT * FROM stock_entries WHERE stock_id='$id'");
760                 
761                 ?>
762
763 <form action=
"edit_purchase.php" method="post" name="edit" onSubmit="updateSubtotal()" >
764
765                  
766                   <table width=
"800" border="0" cellspacing="0" cellpadding="0" >
767                     <tr>
768                       <td width=
"61">&nbsp;</td>
769                       <td width=
"110">&nbsp;</td>
770                       <td width=
"15">&nbsp;</td>
771                       <td width=
"76">&nbsp;</td>
772                       <td width=
"171">&nbsp;</td>
773                       <td width=
"74">&nbsp;</td>
774                       <td width=
"111">&nbsp;</td>
775                       <td width=
"77">&nbsp;</td>
776                       <td width=
"105">&nbsp;</td>
777                     </tr>
778                     <tr>
779                       <td width=
"61">&nbsp;</td>
780                       <td width=
"110">&nbsp;</td>
781                       <td width=
"15">&nbsp;</td>
782                       <td width=
"76">&nbsp;</td>
783                       <td width=
"171">&nbsp;</td>
784                       <td width=
"74">&nbsp;</td>
785                       <td width=
"111">&nbsp;</td>
786                       <td width=
"77">&nbsp;</td>
787                       <td width=
"105">&nbsp;</td>
788                     </tr>
789                     <tr>
790                       <td width=
"61">&nbsp;</td>
791                       <td width=
"110">&nbsp;</td>
792                       <td>&nbsp;</td>
793                       <td><div align=
"left"><strong>ID</strong>
794                               
795                       </div></td>
796                       <td><input name=
"id" type="text" id="id" readonly="" value="<?php echo $line->stock_id; ?>" style="width:50px;">
797                       
798                       </td>
799                       <td><div align=
"left"><strong>Date</strong></div></td>
800                       <td><input type=
"text" id="datefield" name="date" class="date_input" value="<?php
801                       
802                       
803         $phpdate = strtotime( $line->date );
804
805         $phpdate = date("
d-m-Y",$phpdate);
806         echo $phpdate;
807 ?>"
style="width:70px;"></td>
808                       <td>&nbsp;</td>
809                       <td>&nbsp;</td>
810                     </tr>
811                     <tr>
812                       <td width=
"61">&nbsp;</td>
813                       <td width=
"110">&nbsp;</td>
814                       <td width=
"15"><div align="left"></div></td>
815                       <td width=
"76">&nbsp;</td>
816                       <td width=
"171"><div align="left"></div></td>
817                       <td width=
"74">&nbsp;</td>
818                       <td width=
"111"><div align="left"></div></td>
819                       <td width=
"77">&nbsp;</td>
820                       <td width=
"105">&nbsp;</td>
821                     </tr>
822                     <tr>
823                       <td><div align=
"center"><strong>Bill No</strong></div></td>
824                       <td><input type=
"text" name="billnumber" style="width:100px;" id="billnumber" class="validate[required,length[0,100]] text-input" value="<?php echo $line->billnumber; ?>"></td>
825                       <td>&nbsp;</td>
826                       <td><div align=
"left"><strong>Supplier</strong></div></td>
827                       <td><input name=
"supplier" type="text" id="supplier" style="width:100px;" autocomplete="off" value="<?php echo $line->stock_supplier_name; ?> "></td>
828                       <td><div align=
"left">Address</div></td>
829                       <td><textarea name=
"address1" id="address" style="width:100px;"><?php echo $db->queryUniqueValue("SELECT supplier_address FROM supplier_details WHERE supplier_name='$line->stock_supplier_name'"); ?></textarea></td>
830                       <td><div align=
"left">Contact1<br>
831                               <br>
832                         Contact2</div></td>
833                       <td><input name=
"contact1" type="text" id="contact1" value="<?php echo $db->queryUniqueValue("SELECT supplier_contact1 FROM supplier_details WHERE supplier_name='$line->stock_supplier_name'"); ?>" style="width:80px;">
834                           <br>
835                           <br>
836                           <input name=
"contact2" type="text" id="contact2" value="<?php echo $db->queryUniqueValue("SELECT supplier_contact2 FROM supplier_details WHERE supplier_name='$line->stock_supplier_name'"); ?>" style="width:80px;" ></td>
837                     </tr>
838                     <tr>
839                       <td>&nbsp;</td>
840                       <td>&nbsp;</td>
841                       <td><div align=
"left"></div></td>
842                       <td>&nbsp;</td>
843                       <td><div align=
"left"></div></td>
844                       <td>&nbsp;</td>
845                       <td><div align=
"left"></div></td>
846                       <td>&nbsp;</td>
847                       <td>&nbsp;</td>
848                     </tr>
849                    </table>
850
851                   <br>
852                     <?php
853                     $max = $db->maxOf(
"count1", "stock_entries", "stock_id='$id'");
854                     $j=
0;
855                     
for($i=1; $i<=$max; $i++)
856                     {
857                     
858                     ?>
859                     <table width=
"800" border="0" cellspacing="0" cellpadding="0" style="margin-left:20px;">
860                         <tr>
861                       <td ><div align=
"center"><strong>Name</strong></div></td>
862                       <td >
863                       <input name=
"sysid[]" type="hidden" value="<?php echo $line->id; ?>">
864                       <input name=
"name[]" type="text" class="validate[required,length[0,100]] text-input" id="0<?php echo 0+$j;?>" style="width:100px;" onFocus="callAutoComplete(this.id)" onBlur="callAutoAsignValue(this.id)" autocomplete="off" value="<?php
865                       $line1 = $db->queryUniqueObject("
SELECT * FROM stock_entries WHERE stock_id='$id' and count1=$i");
866                       echo $line1->stock_name;
867                       ?>"
></td>
868                       <td><div align=
"left"><strong>Qty</strong></div></td>
869                       <td><input name=
"quantity[]" type="text" id="00<?php echo 1+$j;?>" class="validate[required,custom[onlyFloat],lengthCheck[6]] text-input" style="width:50px;" onKeyUp="callQKeyUp(this.id)" value="<?php echo $line1->quantity;?>"></td>
870                       <td><div align=
"left"><strong>Buy Rate:</strong></div></td>
871                       <td><input name=
"brate[]" type="text" id="000<?php echo 2+$j;?>" class="validate[required,custom[onlyFloat],lengthCheck[6]] text-input" style="width:50px;" onKeyUp="callRKeyUp(this.id)" value="<?php echo $line1->company_price;?>" ></td>
872                       <td>Sales Rate </td>
873                       <td><input name=
"srate[]" type="text" id="0000<?php echo 3+$j;?>" class="validate[optional,custom[onlyFloat],lengthCheck[6]] text-input" style="width:50px;" value="<?php echo $line1->selling_price;?>" ></td>
874                       <td>Avail Qty</td>
875                         <td><input name=
"avail[]" type="text" id="00000<?php echo 4+$j;?>" readonly="" value="<?php echo $db->queryUniqueValue("SELECT quantity FROM stock_avail WHERE name='$line1->stock_name'");?>" style="width:50px;" ></td>
876                       <td><div align=
"left"><strong>Total:</strong></div></td>
877                       <td><input name=
"total[]" type="text" id="000000<?php echo 5+$j;?>" readonly="" value="<?php echo $line1->total;?>" style="width:100px;text-align:right;" > </td>
878                       
879                     </tr>
880                       <tr>
881                         <td>&nbsp;</td>
882                         <td>&nbsp;</td>
883                         <td>&nbsp;</td>
884                         <td>&nbsp;</td>
885                         <td>&nbsp;</td>
886                         <td>&nbsp;</td>
887                         <td>&nbsp;</td>
888                         <td>&nbsp;</td>
889                         <td>&nbsp;</td>
890                         <td>&nbsp;</td>
891                         <td>&nbsp;</td>
892                         <td>&nbsp;</td>
893                         
894                       </tr>
895                       </table>
896                       
897                       <?php
898                       $j=$j+
6;
899                       }
900                       ?>
901                       <table width=
"800" border="0" align="center" cellpadding="0" cellspacing="0" id="duplicate" style="margin-left:20px;">
902                       <tr>
903                         <td>&nbsp;</td>
904                         <td>&nbsp;</td>
905                         <td>&nbsp;</td>
906                         <td>&nbsp;</td>
907                         <td>&nbsp;</td>
908                         <td width=
"103">&nbsp;</td>
909                         <td width=
"140">&nbsp;</td>
910                         <td width=
"5">&nbsp;</td>
911                         <td width=
"5">&nbsp;</td>
912                         <td width=
"5">&nbsp;</td>
913                         <td width=
"13">&nbsp;</td>
914                       </tr>
915                       <tr>
916                         <td>Payment:</td>
917                         <td><input type=
"text" name="payment" style="width:100px; " id="payment" class="validate[required,custom[onlyFloat],lengthCheck[6]] text-input" onKeyUp="balanceCalc()" value="<?php echo $line->payment; ?>" ></td>
918                         <td><div align=
"left">Description</div></td>
919                         <td rowspan=
"2"><textarea name="description" style="width:150px; height:40px; "><?php echo $line->description; ?></textarea></td>
920                         <td>&nbsp;</td>
921                         <td><div align=
"center"><strong>Sub Total </strong></div></td>
922                         <td><input name=
"subtotal" id="subtotal" type="text" readonly="" value="<?php echo $line->subtotal; ?>" style="width:100px; text-align:right; color:#333333; font-weight:bold; font-size:16px;"><img src="images/refresh.png" alt="Refresh" align="absmiddle" onClick="updateSubtotal()"></td>
923                         <td>&nbsp;</td>
924                         <td>&nbsp;</td>
925                         <td>&nbsp;</td>
926                         <td>&nbsp;</td>
927                       </tr>
928                       <tr>
929                         <td>Balance:</td>
930                         <td><input name=
"balance" type="text" id="balance" style="width:100px; " value="<?php echo $line->balance; ?>" readonly=""></td>
931                         <td>&nbsp;</td>
932                         <td>&nbsp;</td>
933                         <td><div align=
"center"></div></td>
934                         <td>&nbsp;</td>
935                         <td>&nbsp;</td>
936                         <td>&nbsp;</td>
937                         <td>&nbsp;</td>
938                         <td>&nbsp;</td>
939                       </tr>
940                       <tr>
941                         <td>&nbsp;</td>
942                         <td>&nbsp;</td>
943                         <td>&nbsp;</td>
944                         <td>&nbsp;</td>
945                         <td>&nbsp;</td>
946                         <td>&nbsp;</td>
947                         <td>&nbsp;</td>
948                         <td>&nbsp;</td>
949                         <td>&nbsp;</td>
950                         <td>&nbsp;</td>
951                         <td>&nbsp;</td>
952                         </tr>
953                       <tr>
954                         <td width=
"55">Mode:</td>
955                         <td width=
"125"><select name="mode">
956                         <option
value="cheque" <?php if($line->mode=="cheque") echo "selected"; ?> >Cheque</option>
957                         <option
value="cash" <?php if($line->mode=="cash") echo "selected"; ?> >Cash</option>
958                         <option
value="others" <?php if($line->mode=="others") echo "selected"; ?> >others</option>
959                         
960                           </
select></td>
961                         <td width=
"77">Due Date </td>
962                         <td width=
"195"><input type="text" id="due" name="due" class="date_input" value="<?php
963         $phpdate = strtotime($line->due);
964
965         $phpdate = date("
d-m-Y",$phpdate);
966         echo $phpdate;
967 ?>"
style="width:70px;"></td>
968                         <td width=
"77">&nbsp;</td>
969                         <td>&nbsp;</td>
970                         <td>&nbsp;</td>
971                         <td>&nbsp;</td>
972                         <td>&nbsp;</td>
973                         <td>&nbsp;</td>
974                         <td>&nbsp;</td>
975                       </tr>
976                       <tr>
977                         <td>&nbsp;</td>
978                         <td>&nbsp;</td>
979                         <td>&nbsp;</td>
980                         <td>&nbsp;</td>
981                         <td>&nbsp;</td>
982                         <td><div align=
"center">
983                            
984                         </div></td>
985                         <td><input type=
"submit" name="Submit" value="Update" onClick="updateSubtotal()" ></td>
986                         <td>&nbsp;</td>
987                         <td>&nbsp;</td>
988                         <td>&nbsp;</td>
989                         <td>&nbsp;</td>
990                         </tr>
991                     </table>
992 </form>
993 <?php
994 }
995 ?>
996                 
997                
998                 <br>
999 <br>
1000 <br>
1001
1002                 
1003   
1004   </td>
1005               </tr>
1006             </table> </td>
1007           </tr>
1008           <tr>
1009           
1010             <td height=
"30" align="center" bgcolor="#72C9F4">
1011             
1012 </div><span
class="style1"><a href="http://www.pluskb.com">Developed by PlusKB Innovations</a></span></td>
1013           </tr>
1014         </table></td>
1015       </tr>
1016     </table></td>
1017   </tr>
1018 </table>
1019
1020
1021 </body>
1022 </html>
1023 <?php
1024 }
1025 ?>


Gõ tìm kiếm nhanh...